<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- modal part start -->
<div class="modal fade signin_modal" id="loginMoadl" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="text-center">登录</h3>
            </div><!--/.modal-header -->
            <div class="modal-body">
                <form  id="user-from">
                    <div class="form-group">
                        <label for="userEmail">邮箱：</label>
                        <input type="email" class="form-control" id="userEmail" name="userEmail" placeholder="">
                    </div><!--/.form-group -->
                    <div class="form-group">
                        <label for="userPassword">密码：</label>
                        <input type="password" class="form-control" id="userPassword" name="userPassword" placeholder="">
                    </div>
                </form>
                    <p class="text-center text-danger" id="userLoginErrorInfo" style="display:none;">
                        邮箱或者密码错误！
                    </p>
                    <div class="form-group text-center">
                        <button type="button" class="btn btn-info" id="btnUserLogin" style="width: 130px;">登录</button>
                    </div>
                <p class="text-center">
                    没有账号？
                    <a href="<%=path%>/register" target="_blank">注册</a>
                </p>
            </div><!--/.modal-body -->
        </div><!--/.modal-content -->
    </div><!--/.modal-dialog -->
</div><!--/.modal -->
<!-- modal part end -->
<script type="text/javascript">
    $("#btnUserLogin").click(function () {
        $.ajax({
            type: "post",
            url: CONTEXT_PATH+"/Consumer/userLogin",
            data: $("#user-from").serialize(), // 序列化form表单里面的数据传到后台
            dataType: "json", // 指定后台传过来的数据是json格式
            success: function(data){
                if(data.code===200){
                    $('#loginMoadl').modal('hide');
                    window.location.reload();
                }else {
                    $("#userLoginErrorInfo").show()
                }
            },
            error: function(err){
                swal("提示","发生错误！","error")
            }
        });
    });

</script>